package main

import (
	"fmt"
	"reflect"
)

func main() {
	var c char
	Str := "golang go..."
	//获取C的类型对象
	TypeofC := reflect.TypeOf(c)
	//Name()获取类型 Kind()获取种类
	fmt.Println("type = ", TypeofC.Name(), "kind = ", TypeofC.Kind())

	Golden := dogs{}
	TypeofGolden := reflect.TypeOf(Golden)
	fmt.Println("type = ", TypeofGolden.Name(), "kind = ", TypeofGolden.Kind())

	TypeofStr := reflect.TypeOf(Str)
	fmt.Println("type = ", TypeofStr.Name(), "kind = ", TypeofStr.Kind())

	huntaway := &dogs{} //指针变量
	TypeofHunt := reflect.TypeOf(huntaway)
	//go语言中所以普指针变量种类都是 ptr
	//指针变量类型此时为空
	fmt.Println("type = ", TypeofHunt.Name(), "kind = ", TypeofHunt.Kind())

	//对指针获取反射对象时，可以通过reflect.Elem()方法获取这个指针指向的元素类
	TypeofHu := TypeofHunt.Elem()
	fmt.Println("type = ", TypeofHu.Name(), "kind = ", TypeofHu.Kind())

}

type char string
type dogs struct {
}
